/*
package com.heima.article.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.article.feign.BehaviorFeign;
import com.heima.article.feign.UserFollowFeign;
import com.heima.article.mapper.ApArticleConfigMapper;
import com.heima.article.mapper.ApArticleContentMapper;
import com.heima.article.mapper.AuthorMapper;
import com.heima.article.service.ApCollectionService;
import com.heima.article.service.ArticleInfoService;
import com.heima.model.article.dtos.ArticleInfoDto;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.model.article.pojos.ApArticleContent;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.article.pojos.ApCollection;
import com.heima.model.behavior.pojos.ApBehaviorEntry;
import com.heima.model.behavior.pojos.ApLikesBehavior;
import com.heima.model.behavior.pojos.ApUnlikesBehavior;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.user.pojos.ApUser;
import com.heima.model.user.pojos.ApUserFollow;
import com.heima.utils.threadlocal.AppThreadLocalUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

//文章详情业务
@Service
public class ApArticleInfoServiceImpl implements ArticleInfoService {

    @Autowired
    private ApArticleConfigMapper apArticleConfigMapper;

    @Autowired
    private ApArticleContentMapper apArticleContentMapper;
    //查询文章详情
    @Override
    public ResponseResult loadArticleInfo(ArticleInfoDto dto) {
        //判断
        if(dto==null || dto.getArticleId()==null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        Map map=new HashMap<>();

        //根据id去查询config表
        ApArticleConfig apArticleConfig = apArticleConfigMapper.selectOne(Wrappers.<ApArticleConfig>lambdaQuery().eq(ApArticleConfig::getArticleId, dto.getArticleId()));
        if(!apArticleConfig.getIsDown() && !apArticleConfig.getIsDelete()){
            //根据id去查询content表
            ApArticleContent apArticleContent = apArticleContentMapper.selectOne(Wrappers.<ApArticleContent>lambdaQuery().eq(ApArticleContent::getArticleId, dto.getArticleId()));
            map.put("content",apArticleContent);
        }
        map.put("config",apArticleConfig);

        return ResponseResult.okResult(map);
    }



    @Autowired
    private BehaviorFeign behaviorFeign;

    @Autowired
    private UserFollowFeign userFollowFeign;

    @Autowired
    private ApCollectionService apCollectionService;

    @Autowired
    private AuthorMapper authorMapper;
    */
/**
     * 加载文章详情的行为内容
     * @param dto
     * @return
     *//*

    @Override
    public ResponseResult loadArticleBehavior(ArticleInfoDto dto) {
        //1.检查参数
        if(dto == null || dto.getArticleId() == null){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        //获取登录用户
        ApUser user = AppThreadLocalUtils.getUser();
        if(user==null){
            return ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);
        }
        //1.行为实体检查
        ApBehaviorEntry  apBehaviorEntry= behaviorFeign.findByUserIdOrEquipmentId(user.getId(), dto.getEquipmentId());
        if(apBehaviorEntry==null){
            return  ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST,"数据不存在");
        }

        //定义返回数据的参数
        boolean islike=false;//是否喜欢
        boolean isunlike=false;//是否不喜欢
        boolean iscollection=false;//是否收藏
        boolean  isfollow=false;//是否关注


        //2.查询 不喜欢的行为数据
        ApUnlikesBehavior apUnlikesBehavior = behaviorFeign.findByArticleIdAndEntryId(dto.getArticleId(), apBehaviorEntry.getId());
        if(apUnlikesBehavior!=null && apUnlikesBehavior.getType()==0){
            isunlike=true;
        }

        //3.查询点赞行为数据
        ApLikesBehavior apLikesBehavior = behaviorFeign.findLikeByArticleIdAndEntryId(dto.getArticleId(), apBehaviorEntry.getId(), (short) 0);
        if(apLikesBehavior!=null && apLikesBehavior.getOperation()==0){
            islike=true;
        }


        //4.收藏数据
        ApCollection apCollection = apCollectionService.findCollectionByEntryIdAndArticleId(apBehaviorEntry.getId(), dto.getArticleId(), (short) 0);
        if(apCollection!=null ){
            iscollection=true;
        }


        //5.是否关注
        ApAuthor apAuthor = authorMapper.selectById(dto.getAuthorId());
        if(apAuthor!=null){
            ApUserFollow apUserFollow = userFollowFeign.findByUserIdAndFollowId(user.getId(), apAuthor.getUserId());
            if(apUserFollow!=null){
                isfollow=true;
            }
        }
        //数据封装
        Map map=new HashMap();
        map.put("isunlike",isunlike);
        map.put("islike",islike);
        map.put("iscollection",iscollection);
        map.put("isfollow",isfollow);

        return ResponseResult.okResult(map);
    }
}
*/
